import request from '@/config/axios'

// 供应商信息 VO
export interface SupplierInfoVO {
  id: number // id
  code: string // 编码(自动编码)
  name: string // 供应商名称
  supplierClassCode: string // 供应商分类编码
  range: string // 经营范围
  scale: string // 公司规模
  postal: string // 公司邮编
  phone: string // 公司电话
  fax: string // 公司传真
  website: string // 公司网站
  country: string // 国家地区
  timeZone: string // 所在时区
  city: string // 所在城市
  harbor: string // 港口
  addressPermanent: string // 常住地址
  addressMail: string // 邮寄地址
  sourceCode: string // 客户来源(关联表：busi_base_cust_source)
  industryCode: string // 行业分类(关联表：busi_base_cust_industry_class)
  priorityCode: string // 客户优先级(关联表：busi_base_cust_priority)
  starCode: string // 客户星级(关联表：busi_base_cust_star)
  stageCode: string // 客户阶段(关联表：busi_base_cust_stage)
  statusCode: string // 客户状态(关联表：busi_base_cust_status)
  remark: string // 备注
}

// 正确定义响应数据类型
interface SupplierQuoteRespVO {
  supplierId: number
  supplierName: string
  supplierType: string
  num: number
  unit: string
  model: string
  price: number
  amount: number
  createTime: string
  validity: string
}

interface SupplierClassInfoVO{
 id:number
 code:string
 type:string
 orderId:number
 remark:string
createTime:string;
}
// 查询供应商报价分页
export const getSupplierQuotePage = (params: any) => {
  return request.get<CommonResult<PageResult<SupplierQuoteRespVO>>>({
    url: '/business/supplier-info/supplier-quote-page',
    params
  })
}

export interface SupplierContactsRespVO {
  id: number;
  supplierId: number;
  name: string;
  phone: string;
  email: string;
  position: string;
  department: string;
  isDefault: boolean;
  remark: string;
  // 可根据实际字段添加更多属性
}



// 供应商信息 API
export const SupplierInfoApi = {

  deleteSupplierQuote:async(id:number)=>{
    return await request.delete({ url: `/business/supplier-info/delete-supplier-quote?id=` + id })
  },

  batchDeleteSupplierQuote:async(ids:number[])=>{
    return request.post({ 
      url: '/business/supplier-info/batch-delete',
      data: ids // 传递包含ids数组的对象
    })
  },

 updateSupplierQuote:async (data: any) => {
    return await request.put({ url: '/business/supplier-info/updateQuote', data })
  },
  // 查询供应商信息分页
  getSupplierInfoPage: async (params: any) => {
    return await request.get({ url: `/business/supplier-info/page`, params })
  },

  // 查询供应商信息详情
  getSupplierInfo: async (id: number) => {
    return await request.get({ url: `/business/supplier-info/get?id=` + id })
  },

  // 新增供应商信息
  createSupplierInfo: async (data: SupplierInfoVO) => {
    return await request.post({ url: `/business/supplier-info/create`, data })
  },

  // 修改供应商信息
  updateSupplierInfo: async (data: SupplierInfoVO) => {
    return await request.put({ url: `/business/supplier-info/update`, data })
  },

  // 删除供应商信息
  deleteSupplierInfo: async (id: number) => {
    return await request.delete({ url: `/business/supplier-info/delete?id=` + id })
  },

  // 导出供应商信息 Excel
  exportSupplierInfo: async (params) => {
    return await request.download({ url: `/business/supplier-info/export-excel`, params })
  },
  getSupplierClassList:async ()=>{
    return await request.get({url:'/business/supplier-info/getClassList'});
  },

  addSupplierQuote:async (data: any) => {
    return await request.post({url: '/business/supplier-info/createSupplierPronInfo',data})
  },
}


